<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./promise.js"></script>
</head>
<body>
  <script>
    // const p = new MyPromise((resolve, reject) => {
    //   setTimeout(() => {
    //     resolve(1000)
    //   }, 1000)
    //   // resolve(11)
    //   // reject('error')

    //   // throw('error1')
    // }).then((res) => console.log(res), (error) => console.log(error))

    // const test3 = new MyPromise((resolve, reject) => {
    //   resolve(100) // 输出 状态：success 值： 200
    // }).then(res => {
    //   return 2 * res
    //   // console.log(111111)
    // }, err => 3 * err)
    //   .then(res => {
    //     console.log('success', res);
    //   }, err => console.log('fail', err))


    // const test4 = new MyPromise((resolve, reject) => {
    //   setTimeout(() => {
    //     resolve(100) // 输出 状态：fail 值：200
    //   }, 1000)
    //   }).then(res => {
    //     return new MyPromise((resolve, reject) => {
    //       reject(2 * res)
    //     })
    //   }, err => new Promise((resolve, reject) => resolve(3 * err)))
    //     .then(res => console.log('success', res), err => console.log('fail', err))

      const test5 = new MyPromise((resolve, reject) => {
        console.log('0000');
        resolve(1)
      }).then(res => console.log(res), err => console.log(err))

      console.log(2)

  </script>
</body>
</html>